<?php
	require_once("pre.php");
	require_once("auth.php");

	if(!isset($action)) $action="";
	if(!isset($lang)) $lang=$_SESSION["util"]->lang;
	if(!isset($ligne)) $ligne="";
?>
<?php if(! est_autorise("acces_contenu")) exit; ?>
<?php
	require_once("../classes/Dossier.class.php");
	require_once("../classes/Rubrique.class.php");
	require_once("../fonctions/divers.php");
	require_once("../classes/Image.class.php");
    require_once("../classes/Document.class.php");
    require_once("../classes/Zone.class.php");
    require_once("../classes/Pays.class.php");
    require_once("../classes/Lang.class.php");
    require_once("../classes/Reecriture.class.php");
?>
<?php

	switch($action){
		case 'modclassement' : modclassement($id, $parent, $type); break;
		case 'modifier' : modifier($id, $lang, $dossier, $ligne, $titre, $chapo, $description, $postscriptum, $urlsuiv, $urlreecrite); break;
		case 'ajouter' : ajouter($lang, $dossier, $ligne, $titre, $chapo, $description, $postscriptum); break;
		case 'supprimer' : supprimer($id, $parent); break;
		case 'ajouterphoto' : ajouterphoto($id,$lang); break;
		case 'modifierphoto' : modifierphoto($id_photo,$titre_photo,$chapo_photo,$description_photo,$lang); break;
		case 'supprimerphoto' : supprimerphoto($id_photo,$lang); break;
		case 'modclassementphoto' : modclassementphoto($id_photo,$type); break;
		case 'ajouterdoc' : ajouterdoc($id, $_FILES['doc']['tmp_name'], $_FILES['doc']['name'],$lang); break;
		case 'modifierdoc' : modifierdoc($id_document,$titredoc,$chapodoc,$descriptiondoc,$lang); break;
		case 'supprimerdoc' : supprimerdoc($id_document,$lang); break;
		case 'modclassementdoc' : modclassementdoc($id_document,$type); break;

	}

?>
<?php

	function modclassementdoc($id, $type){

      	$doc = new Document();
        $doc->charger($id);
        $doc->changer_classement($id, $type);
	}

	function supprimerdoc($id,$lang){

			$tmp = new Contenu();
			$tmp->charger($_REQUEST['id']);

			$document = new Document();
			$document->charger($id);

			if(file_exists("../client/document/$document->fichier")){
				 unlink("../client/document/$document->fichier");
			}

			$document->supprimer();
		    header("Location: contenu_modifier.php?id=" . $tmp->id."&dossier=".$tmp->dossier."&lang=".$lang);
	}

	function modifierdoc($id, $titre, $chapo, $description,$lang){

		$tmp = new Contenu();
		$tmp->charger($_REQUEST['id']);

		$documentdesc = new Documentdesc();
		$documentdesc->document = $id;
		$documentdesc->lang = $lang;

		$documentdesc->charger($id,$lang);

		$documentdesc->titre = $titre;
		$documentdesc->chapo = $chapo;
		$documentdesc->description = $description;

		if(!$documentdesc->id)
			$documentdesc->add();
		else
			$documentdesc->maj();

	    header("Location: contenu_modifier.php?id=" . $tmp->id."&dossier=".$tmp->dossier."&lang=".$lang);

	}

	function ajouterdoc($contenu, $doc, $doc_name,$lang){

		$tmp = new Contenu();
		$tmp->charger($_REQUEST['id']);

		if($doc != ""){

			$fich = substr($doc_name, 0, strlen($doc_name)-4);
			$ext = substr($doc_name, strlen($doc_name)-3);

			$document = new Document();
			$documentdesc = new Documentdesc();

		 	$query = "select max(classement) as maxClassement from $document->table where contenu='" . $contenu . "'";

	 		$resul = mysql_query($query, $document->link);
     		$maxClassement = mysql_result($resul, 0, "maxClassement");

			$document->contenu = $contenu;
			$document->classement = $maxClassement+1;

			$lastid = $document->add();
			$document->charger($lastid);
			$fich = eregfic($fich);
			$document->fichier = $fich . "_" . $contenu . "." . $ext;
			$document->maj();

			copy("$doc", "../client/document/" . $fich . "_" . $contenu . "." . $ext);

			header("location: contenu_modifier.php?id=".$tmp->id."&dossier=".$tmp->dossier."&lang=".$lang);
		}

	}

	function modclassementphoto($id, $type){
      	$img = new Image();
        $img->charger($id);
        $img->changer_classement($id, $type);
	}

	function supprimerphoto($id,$lang){

			$tmp = new Contenu();
			$tmp->charger($_REQUEST['id']);

			$image = new Image();
			$image->charger($id);

			$imagedesc = new Imagedesc();
			$imagedesc->charger($image->id);

			if(file_exists("../client/gfx/photos/contenu/$image->fichier"))
				 unlink("../client/gfx/photos/contenu/$image->fichier");


			$image->supprimer();
			$imagedesc->delete();

			header("location: contenu_modifier.php?id=".$tmp->id."&dossier=".$tmp->dossier."&lang=".$lang);

	}

	function modifierphoto($id, $titre, $chapo, $description,$lang){
		$tmp = new Contenu();
		$tmp->charger($_REQUEST['id']);

		$imagedesc = new Imagedesc();
		$imagedesc->image = $id;
		$imagedesc->lang = $lang;

		$imagedesc->charger($id,$lang);

		$imagedesc->titre = $titre;
		$imagedesc->chapo = $chapo;
		$imagedesc->description = $description;

		if(!$imagedesc->id)
			$imagedesc->add();
		else
			$imagedesc->maj();

		header("location: contenu_modifier.php?id=".$tmp->id."&dossier=".$tmp->dossier."&lang=".$lang);

	}

	function ajouterphoto($id,$lang){

		$tmp = new Contenu();
		$tmp->charger($_REQUEST['id']);

		if(!isset($nomorig)) $nomorig="";

		for($i = 1; $i<6; $i++){
			$photo = $_FILES["photo" . $i]['tmp_name'];
			$photo_name = $_FILES["photo" . $i]['name'];

		if($photo != ""){

	        preg_match("/([^\/]*).((jpg|gif|png|jpeg))/i", $photo_name, $decoupe);

			$fich = eregfic($decoupe[1]);
       	    $extension = $decoupe[2];

			if($fich == "" || $extension == "")
				return 0;

			$image = new Image();
			$imagedesc = new Imagedesc();


		 	$query = "select max(classement) as maxClassement from $image->table where contenu='" . $id . "'";

	 		$resul = mysql_query($query, $image->link);
     		$maxClassement = mysql_result($resul, 0, "maxClassement");


			$image->contenu = $id;
			$image->classement = $maxClassement + 1;

			$lastid = $image->add();

			$image->charger($lastid);
			$image->fichier = ereg_caracspec($fich . "_" . $lastid) . "." . strtolower($extension);
			$image->maj();

			copy("$photo", "../client/gfx/photos/contenu/" . $image->fichier);

			ActionsModules::instance()->appel_module("uploadimage", $image);

			header("location: contenu_modifier.php?id=".$tmp->id."&dossier=".$tmp->dossier."&lang=".$lang);
		}
	 }
	}

	function modclassement($id, $parent, $type){

      	$cont = new Contenu();
        $cont->charger($id);
        $cont->changer_classement($id, $type);

	    header("Location: listdos.php?parent=" . $parent);
	}


	function modifier($id, $lang, $dossier, $ligne, $titre, $chapo, $description, $postscriptum, $urlsuiv, $urlreecrite){

	 if(!isset($id)) $id="";

		if(!$lang) $lang=1;

		$contenu = new Contenu();
		$contenudesc = new Contenudesc();
		$contenu->charger($id);
		$res = $contenudesc->charger($contenu->id, $lang);


		if(!$res){
			CacheBase::getCache()->reset_cache();
			$temp = new Contenudesc();
			$temp->contenu=$contenu->id;
			$temp->lang=$lang;
			$lastid = $temp->add();
			$contenudesc = new Contenudesc();
			$contenudesc->charger_id($lastid);
		}

		 $contenu->datemodif = date("Y-m-d H:i:s");
		
		if($contenu->dossier != $dossier){
			$query = "select max(classement) as maxClassement from $contenu->table where dossier='" . $dossier . "'";
			$resul = mysql_query($query, $contenu->link);
			$contenu->classement =  mysql_result($resul, 0, "maxClassement") + 1;

			$reecriture = new Reecriture();
			$query_reec = "select * from $reecriture->table where param=\"&id_contenu=" . $contenu->id . "&id_dossier=" . $contenu->dossier . "\" and lang=$lang and actif=1";
			$resul_reec = mysql_query($query_reec, $reecriture->link);
			while($row_reec = mysql_fetch_object($resul_reec)){
				$tmpreec = new Reecriture();
				$tmpreec->charger_id($row_reec->id);
				$tmpreec->param = "&id_contenu=" . $contenu->id . "&id_dossier=" . $dossier;
				$tmpreec->maj();
			}
		}		
		
		
		 $contenu->dossier = $dossier;
	 	 if($ligne == "on") $contenu->ligne = 1; else $contenu->ligne = 0;
		 $contenudesc->chapo = $chapo;
		 $contenudesc->description = $description;
		 $contenudesc->postscriptum = $postscriptum;
		 $contenudesc->titre = $titre;

	 	 $contenudesc->chapo = str_replace("\n", "<br/>", $contenudesc->chapo);

		$contenu->maj();
		$contenudesc->maj();

 	    $contenudesc->reecrire($urlreecrite);

		ActionsModules::instance()->appel_module("modcont", $contenu);

		if($urlsuiv) header("location: listdos.php?parent=".$contenu->dossier);
	    else header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $contenu->id . "&dossier=" . $contenu->dossier ."&lang=".$lang);
		exit;
	}

	function ajouter($lang, $dossier, $ligne, $titre, $chapo, $description, $postscriptum){

 	 	if(!isset($id)) $id="";

 	 	$contenu = new Contenu();
	 	$contenu->charger($id);

   	 	if($contenu->id) return;

	 	$contenu = new Contenu();

	 	$query = "select max(classement) as maxClassement from $contenu->table where dossier='" . $dossier . "'";

	 	$resul = mysql_query($query, $contenu->link);
     	$maxClassement = mysql_result($resul, 0, "maxClassement");

	 	$contenu->datemodif = date("Y-m-d H:i:s");
	 	$contenu->dossier = $dossier;
	 	if($ligne == "on") $contenu->ligne = 1; else $contenu->ligne = 0;
	 	$contenu->classement = $maxClassement + 1;

	 	$lastid = $contenu->add();
		$contenu->id = $lastid;

	 	$contenudesc = new Contenudesc();

	 	$contenudesc->chapo = $chapo;
	 	$contenudesc->description = $description;
	 	$contenudesc->postscriptum = $postscriptum;
	 	$contenudesc->contenu = $lastid;
	 	$contenudesc->lang = $lang;
	 	$contenudesc->titre = $titre;

	 	$contenudesc->chapo = str_replace("\n", "<br/>", $contenudesc->chapo);
     	$contenudesc->postscriptum = str_replace("\n", "<br/>", $contenudesc->postscriptum);

	 	$contenudesc->add();

		$contenudesc->reecrire();

		ActionsModules::instance()->appel_module("ajoutcont", $contenu);

	    header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $lastid . "&dossier=" . $contenu->dossier);
		exit;

	}

	function supprimer($id, $parent){

		$contenu = new Contenu();
		$contenu->charger($id);
		$contenu->supprimer();

		ActionsModules::instance()->appel_module("supcont", $contenu);

	    header("Location: listdos.php?parent=" . $parent);
		exit;
	}

?>
<?php

	if(!isset($id)) $id="";

	$contenu = new Contenu();
	$contenudesc = new Contenudesc();

	$contenu->charger($id);
	$contenudesc->charger($contenu->id, $lang);

	$contenudesc->chapo = str_replace("<br/>", "\n", $contenudesc->chapo);
	$contenudesc->postscriptum = str_replace("<br/>", "\n", $contenudesc->postscriptum);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php require_once("title.php"); ?>

<script type="text/javascript" src="../lib/jquery/jquery.js"></script>

</head>

<body>
<div id="wrapper">
<div id="subwrapper">

<?php
	$menu="contenu";
	require_once("entete.php");
?>
<div id="contenu_int">
  <p align="left"><a href="accueil.php" class="lien04"><?php echo trad('Accueil'); ?> </a> <img src="gfx/suivant.gif" width="12" height="9" border="0" /><a href="listdos.php" class="lien04"><?php echo trad('Gestion_contenu'); ?> </a>

    <?php
    				$cont = new Contenu();
    				$cont->charger($id);

    				$contdesc = new Contenudesc();
    				$contdesc->charger($cont->id, $_SESSION['util']->lang);

					$parentnom = $contdesc->titre;

					if($cont->dossier) $res = chemin_dos($cont->dossier, $_SESSION['util']->lang);
					else $res = chemin_dos($dossier, $_SESSION['util']->lang);

					$tot = count($res)-1;

?>



			<?php
				if($cont->dossier || $dossier){

			?>
				<img src="gfx/suivant.gif" width="12" height="9" border="0" />
			<?php
				}

				while($tot --){
			?><a href="listdos.php?parent=<?php echo($res[$tot+1]->dossier); ?>" class="lien04"><?php echo($res[$tot+1]->titre); ?></a> <img src="gfx/suivant.gif" width="12" height="9" border="0" />
			<?php
            	}

            ?>

			<?php
                    $parentdesc = new Dossierdesc();
                    if($cont->dossier)
						$parentdesc->charger($cont->dossier, $_SESSION['util']->lang);
					else $parentdesc->charger($dossier, $_SESSION['util']->lang);

					$parentnom = $parentdesc->titre;


			?>
			<a href="listdos.php?parent=<?php echo($parentdesc->dossier); ?>" class="lien04"><?php echo($parentdesc->titre); ?></a> <img src="gfx/suivant.gif" width="12" height="9" border="0" />

			 <?php if( $id) { ?>

			<a href="#" class="lien04"><?php echo($contdesc->titre); ?></a> <img src="gfx/suivant.gif" width="12" height="9" border="0" />
           <?php echo trad('Modifier'); ?><?php } else { ?> <?php echo trad('Ajouter'); ?> <?php } ?> </p>

<div id="bloc_description">
 <form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post" id="formulaire" enctype="multipart/form-data">
	<input type="hidden" name="action" value="<?php if(!$id) { ?>ajouter<?php } else { ?>modifier<?php } ?>" />
	<input type="hidden" name="id" value="<?php echo($id); ?>" />
 	<input type="hidden" name="lang" value="<?php echo($lang); ?>" />
 	<input type="hidden" name="dossier" value="<?php echo($dossier); ?>" />
	<input type="hidden" name="urlsuiv" id="url" value="0" />

<!-- bloc descriptif du produit -->
		<div class="entete">
			<div class="titre"><?php echo trad('DESCRIPTION_G'); ?></div>
			<div class="fonction_valider"><a href="#" onclick="document.getElementById('formulaire').submit()"><?php echo trad('VALIDER_LES_MODIFICATIONS'); ?></a></div>
		</div>
	<table width="100%" cellpadding="5" cellspacing="0">
	<?php if($id){ ?>
    <tr class="claire">
        <th class="designation"><?php echo trad('Changer_langue'); ?></th>
        <th>
        <?php
			$langl = new Lang();
			$query = "select * from $langl->table";
			$resul = mysql_query($query);
			while($row = mysql_fetch_object($resul)){
			$langl->charger($row->id);
			
			$ttrad = new Dossierdesc();
			if(! $ttrad->charger($contenu->dossier, $row->id))
				continue;
							
		?>
		<div class="flag<?php if($lang ==  $langl->id) { ?>Selected<?php } ?>">
		<a href="<?php echo($_SERVER['PHP_SELF']); ?>?id=<?php echo($id); ?>&dossier=<?php echo($dossier); ?>&lang=<?php echo($langl->id); ?>"><img src="gfx/lang<?php echo($langl->id); ?>.gif" /></a></div>
		<?php } ?>
</th>
   	</tr>
	<?php } ?>
   	<tr class="fonce">
        <td class="designation"><?php echo trad('Titre'); ?></td>
        <td><input name="titre" id="titre" type="text" class="form_long" value="<?php echo htmlspecialchars($contenudesc->titre); ?>" /></td>
   	</tr>
   	<tr class="claire">
        <td class="designation"><?php echo trad('Chapo'); ?><br /> <span class="note"><?php echo trad('courte_descript_intro'); ?></span></td>
        <td> <textarea name="chapo" id="chapo" cols="40" rows="2" class="form_long"><?php echo($contenudesc->chapo); ?></textarea></td>
   	</tr>
   	<tr class="fonce">
        <td class="designation">Description<br /> <span class="note"><?php echo trad('description_complete'); ?></span></td>
        <td>
        <textarea name="description" id="description" cols="40" rows="20"><?php echo($contenudesc->description); ?></textarea></td>
   	</tr>
   	<tr class="claire">
        <td class="designation">Postscriptum<br /> <span class="note"><?php echo trad('champs_info_complementaire'); ?></span></td>
        <td><textarea name="postscriptum" id="postscriptum" cols="40" rows="2" class="form_long"><?php echo($contenudesc->postscriptum); ?></textarea></td>
   	</tr>
   <?php
	if($id != ""){
   ?>
   <tr class="fonce">
      <td class="designation"><?php echo trad('Appartenance'); ?><br /> <span class="note"><?php echo trad('deplacer'); ?></span></td>
      <td style="vertical-align:top;">
        <select name="dossier" id="dossier"  class="form_long">
      		<?php if($id) echo arbreOption_dos(0, 1, $contenu->dossier, $_GET['dossier'], -1, $lang); else echo arbreOption_dos(0, 1, $dossier,  $_GET['dossier'], -1, $lang); ?>
      	</select>
        </span></td>
    </tr>
  <?php
	}
   ?>
	<tr class="claire">
      <td class="designation"><?php echo trad('En_ligne'); ?></td>
      <td>    <input type="checkbox" name="ligne" id="ligne" class="form" <?php if($contenu->ligne || $contenu->ligne == "") echo "checked"; ?> /></td>
    </tr>
    </table>
<?php if($id != ""){ ?>

<!-- bloc d'informations sur le contenu-->
		<div class="entete">
			<div class="titre" style="cursor:pointer" onclick="$('#pliantsinfos').show('slow');"><?php echo trad('INFO_CONTENU'); ?></div>
			<div class="fonction_valider"><a href="#" onclick="document.getElementById('formulaire').submit()"><?php echo trad('VALIDER_LES_MODIFICATIONS'); ?></a></div>
		</div>

<div class="blocs_pliants_prod" id="pliantsinfos">

				<ul class="lignesimple">
					<li class="cellule_designation" style="width:140px; background-image:url(gfx/degrade_ligne1.png); background-repeat: repeat-x;">ID</li>
					<li class="cellule" style="width:438px; padding: 5px 0 0 5px; background-image:url(gfx/degrade_ligne1.png); background-repeat: repeat-x;"><?php echo($contenu->id); ?></li>
				</ul>

			<ul class="lignesimple">
				<li class="cellule_designation" style="width:140px;"><?php echo trad('URL_reecrite'); ?></li>
				<li class="cellule"><input type="text" name="urlreecrite" value="<?php echo htmlspecialchars(rewrite_cont("$contenu->id", $lang)); ?>" class="form_long" /></li>
			</ul>

		<div class="bloc_fleche" style="cursor:pointer" onclick="$('#pliantsinfos').hide();"><img src="gfx/fleche_accordeon_up.gif" /></div>

</div>
 <?php } ?>
 <?php
	ActionsAdminModules::instance()->inclure_module_admin("contenumodifier");
 ?>
   </form>

</div>
 <?php if($id != ""){ ?>
<!-- bloc de gestion des photos et documents / colonne de droite -->
<div id="bloc_photos">
<!-- début du bloc Boite à outils du contenu -->
<div class="entete">
	<div class="titre"><?php echo trad('BOITE_OUTILS'); ?></div>
</div>
<div class="bloc_transfert">
	<div class="claire">
		<div class="champs" style="padding-top:10px; width:375px;">
			<?php
			$query = "select max(classement) as maxcount from $contenu->table where dossier=$contenu->dossier";
			$resul = mysql_query($query);
			$maxclassement = mysql_result($resul,0,"maxcount");

			$query = "select min(classement) as mincount from $contenu->table where dossier=$contenu->dossier";
			$resul = mysql_query($query);
			$minclassement = mysql_result($resul,0,"mincount");

			$urlsite = new Variable("urlsite");

			$classement = $contenu->classement;
			if($classement>$minclassement){
				$prec = $contenu->classement;
				do{
					$prec--;
					$query = "select id from $contenu->table where dossier=$contenu->dossier and classement=$prec";
					$resul = mysql_query($query);
				}while(!mysql_num_rows($resul) && $prec > $minclassement);

				if(mysql_num_rows($resul) != 0){
					$idprec = mysql_result($resul,0,"id");
			?>
			<a href="contenu_modifier.php?id=<?php echo $idprec; ?>&dossier=<?php echo $contenu->dossier; ?>"><img src="gfx/precedent.png" alt="Contenu précédent" title="Contenu précédent" style="padding:0 5px 0 0;margin-top:-5px;height:38px;"/></a>
			<?php
				}
			}
			?>
			<!-- pour visualiser la page contenu correspondante en ligne -->
			<a title="Voir le contenu en ligne" href="<?php echo $urlsite->valeur; ?>/?fond=contenu&id_contenu=<?php echo $contenu->id; ?>" target="_blank" ><img src="gfx/site.png" alt="Voir le contenu en ligne" title="Voir le contenu en ligne" /></a>
			<a href="#" onclick="document.getElementById('formulaire').submit();"><img src="gfx/valider.png" alt="Enregistrer les modifications" title="Enregistrer les modifications" style="padding:0 5px 0 0;"/></a>
			<a href="#" onclick="document.getElementById('url').value='1'; document.getElementById('formulaire').submit();"><img src="gfx/validerfermer.png" alt="Enregistrer les modifications et fermer la fiche" title="Enregistrer les modifications et fermer la fiche" style="padding:0 5px 0 0;"/></a>
			<?php
			if($classement<$maxclassement){
				$suivant = $contenu->classement;
				do{
					$suivant++;
					$query = "select id from $contenu->table where dossier=$contenu->dossier and classement=$suivant";
					$resul = mysql_query($query);
				}while(!mysql_num_rows($resul) && $suivant<$maxclassement);

				if(mysql_num_rows($resul) != 0){
					$idsuiv = mysql_result($resul,0,"id");
			?>
			<a href="contenu_modifier.php?id=<?php echo $idsuiv; ?>&dossier=<?php echo $contenu->dossier; ?>" ><img src="gfx/suivant.png" alt="Contenu suivant" title="Contenu suivant" style="padding:0 5px 0 0;"/></a>
			<?php
				}
			}
			?>
		</div>
   	</div>
</div>
<!-- fin du bloc Boite à outils du contenu-->

<!-- début du bloc de transfert des images du contenu-->
<div class="entete" style="margin-top:10px;">
	<div class="titre"><?php echo trad('GESTION_PHOTOS'); ?></div>
</div>
<!-- bloc transfert des images -->
<div class="bloc_transfert">
	<div class="claire">
		<div class="designation" style="height:160px; padding-top:10px;"><?php echo trad('Transferer_images'); ?></div>
		<div class="champs" style="padding-top:10px;">
			<form action="contenu_modifier.php" method="post" enctype="multipart/form-data">
				<input type="hidden" name="action" value="ajouterphoto" />
      			<input type="hidden" name="id" value="<?php echo($id); ?>" />
      			<?php for($i=1; $i<6; $i++) { ?>
	      			<input type="file" id="photo<?php echo($i); ?>" name="photo<?php echo($i); ?>" class="form" /><br/>
	  			<?php } ?>
	        	<input type="submit" value="<?php echo trad('Ajouter'); ?>" />
   			</form>
   		</div>
   	</div>
</div>
<!-- fin du bloc de transfert des images du contenu-->

<!-- début du bloc de gestion des photos du contenu -->
<div class="bloc_fleche" style="cursor:pointer" onclick="$('#pliantsphotos').show('slow');"><img src="gfx/fleche_accordeon_img_dn.gif" /></div>
<div class="blocs_pliants_photo" id="pliantsphotos">
	<ul>
   <?php
			$image = new Image();

			$query = "select * from $image->table where contenu='$id' order by classement";
			$resul = mysql_query($query, $image->link);

			while($row = mysql_fetch_object($resul)){
				$imagedesc = new Imagedesc();
				$imagedesc->charger($row->id,$lang);
   ?>
		<form action="contenu_modifier.php" method="post">
		<input type="hidden" name="action" value="modifierphoto" />
		<input type="hidden" name="id_photo" value="<?php echo $row->id; ?>" />
		<input type="hidden" name="id" value="<?php echo $id; ?>" />
		<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
		<input type="hidden" name="dossier" value="<?php echo $contenu->dossier; ?>" />


			<li class="lignesimple">
				<div class="cellule_designation" style="height:208px;">&nbsp;</div>
				<div class="cellule_photos" style="height:200px; overflow:hidden;"><a href="../client/gfx/photos/contenu/<?php echo($row->fichier); ?>" target="_blank"><img src="../fonctions/redimlive.php?type=contenu&nomorig=<?php echo($row->fichier); ?>&width=&height=200&opacite=&nb=" border="0" /></a></div>
				<div class="cellule_supp"><a href="contenu_modifier.php?id_photo=<?php echo($row->id); ?>&id=<?php echo($id); ?>&action=supprimerphoto&lang=<?php echo $lang; ?>&dossier=<?php echo $dossier; ?>"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></div>
			</li>
			<li class="lignesimple">
				<div class="cellule_designation" style="height:30px;"><?php echo trad('Titre'); ?></div>
				<div class="cellule">
				<input type="text" name="titre_photo" style="width:219px;" class="form" value="<?php echo  htmlspecialchars($imagedesc->titre) ?>" />
				</div>
			</li>
			<li class="lignesimple">
				<div class="cellule_designation" style="height:50px;"><?php echo trad('Chapo'); ?></div>
				<div class="cellule"><textarea name="chapo_photo" rows="2"class="form" style="width:219px;"><?php echo $imagedesc->chapo ?></textarea></div>
			</li>
			<li class="lignesimple">
				<div class="cellule_designation" style="height:65px;"><?php echo trad('Description'); ?></div>
				<div class="cellule"><textarea name="description_photo" class="form" rows="3" style="width:219px;"><?php echo $imagedesc->description ?></textarea></div>
			</li>
			<li class="lignesimple">
				<div class="cellule_designation" style="height:30px;"><?php echo trad('Classement'); ?></div>
				<div class="cellule">
					<div class="classement">
						<a href="<?php echo $_SERVER['PHP_SELF'] . "?id_photo=".$row->id."&action=modclassementphoto&type=M&id=".$id."&lang=".$lang; ?>"><img src="gfx/up.gif" border="0" /></a></div>
					<div class="classement">
						<a href="<?php echo $_SERVER['PHP_SELF'] . "?id_photo=".$row->id."&action=modclassementphoto&type=D&id=".$id."&lang=".$lang; ?>"><img src="gfx/dn.gif" border="0" /></a></div>
				</div>

			</li>
			<li class="lignesimple">
				<div class="cellule_designation" style="height:30px;">&nbsp;</div>
				<div class="cellule" style="height:30px; border-bottom: 1px dotted #9DACB6"><input type="submit" value="<?php echo trad('Enregistrer'); ?>" /></div>
			</li>

		</form>
   		<?php } ?>
   		</ul>
<div class="bloc_fleche" style="cursor:pointer" onclick="$('#pliantsphotos').hide();"><img src="gfx/fleche_accordeon_img_up.gif" /></div>
</div>
<!-- fin du bloc de gestion des photos du contenu -->

<!-- début du bloc de transfert des documents du contenu -->
<div class="entete" style="margin-top:10px;">
	<div class="titre"><?php echo trad('GESTION_DOCUMENTS'); ?></div>
</div>
<!-- bloc transfert des documents -->
<div class="bloc_transfert">
	<div class="claire">
		<div class="designation" style="height:70px; padding-top:10px;"><?php echo trad('Transferer_documents'); ?></div>
		<div class="champs" style="padding-top:10px;">
			<form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post" enctype="multipart/form-data">
				<input type="hidden" name="action" value="ajouterdoc" />
      			<input type="hidden" name="id" value="<?php echo($id); ?>" />
				<input type="hidden" name="dossier" value="<?php echo($dossier); ?>" />
				<input type="hidden" name="lang" value="<?php echo($lang); ?>" />
      			<input type="file" id="doc" name="doc" class="form" /><br/>
      			<input type="submit" value="<?php echo trad('Ajouter'); ?>" />
    		</form>
		</div>
	</div>
</div>
<!-- fin du bloc transfert des documents du contenu -->
<!-- début du bloc de gestion des documents du contenu -->
<div class="bloc_fleche" style="cursor:pointer" onclick="$('#pliantsfichier').show('slow');"><img src="gfx/fleche_accordeon_img_dn.gif" /></div>
<div class="blocs_pliants_fichier" id="pliantsfichier">
	<ul>
   	  <?php
			$document = new Document();
			$documentdesc = new Documentdesc();

			$query = "select * from $document->table where contenu='$id' order by classement";
			$resul = mysql_query($query, $document->link);

			while($row = mysql_fetch_object($resul)){
				$document = new Document();
				$documentdesc = new Documentdesc();

				$documentdesc->charger($row->id,$lang);
        ?>
             <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
				<input type="hidden" name="action" value="modifierdoc" />
				<input type="hidden" name="id" value="<?php echo $id; ?>" />
				<input type="hidden" name="id_document" value="<?php echo $row->id; ?>" />
				<input type="hidden" name="dossier" value="<?php echo($dossier); ?>" />
				<input type="hidden" name="lang" value="<?php echo($lang); ?>" />

   				<li class="lignesimple">
				<div class="cellule_designation"><?php echo trad('Fichier'); ?></div>
				<div class="cellule_document"><a href="../client/document/<?php echo($row->fichier); ?>" target="_blank"><?php if(strlen($row->fichier) > 26) echo(substr($row->fichier,0,26)." ... ".substr($row->fichier,strlen($row->fichier)-3,strlen($row->fichier)));
				else echo $row->fichier; ?></a></div>
				<div class="cellule_supp_fichier">
				<a href="contenu_modifier.php?id=<?php echo($id); ?>&id_document=<?php echo($row->id); ?>&action=supprimerdoc&lang=<?php echo $lang; ?>&dossier=<?php echo $dossier; ?>"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></div>
				</li>
			<li class="lignesimple">
				<div class="cellule_designation" style="height:30px;"><?php echo trad('Titre'); ?></div>
				<div class="cellule">
				<input type="text" name="titredoc" style="width:219px;" class="form" value="<?php echo htmlspecialchars($documentdesc->titre); ?>" />
				</div>
			</li>
			<li class="lignesimple">
				<div class="cellule_designation" style="height:50px;"><?php echo trad('Chapo'); ?></div>
				<div class="cellule"><textarea name="chapodoc" rows="2" class="form" style="width:219px;"><?php echo $documentdesc->chapo ?></textarea>
				</div>
			</li>
			<li class="lignesimple">
				<div class="cellule_designation" style="height:65px;"><?php echo trad('Description'); ?></div>
				<div class="cellule"><textarea name="descriptiondoc" class="form" rows="3" style="width:219px;"><?php echo $documentdesc->description ?></textarea></div>
			</li>
			<li class="lignesimple">
				<div class="cellule_designation" style="height:30px;"><?php echo trad('Classement'); ?></div>
				<div class="cellule">
					<div class="classement">
						<a href="<?php echo $_SERVER['PHP_SELF'] . "?id=".$id."&id_document=".$row->id."&action=modclassementdoc&type=M&dossier=".$dossier."&lang=".$lang; ?>"><img src="gfx/up.gif" border="0" /></a></div>
					<div class="classement">
						<a href="<?php echo $_SERVER['PHP_SELF'] . "?id=".$id."&id_document=".$row->id."&action=modclassementdoc&type=D&dossier=".$dossier."&lang=".$lang; ?>"><img src="gfx/dn.gif" border="0" /></a></div>
				</div>

			</li>
			<li class="lignesimple">
				<div class="cellule_designation" style="height:30px;">&nbsp;</div>
				<div class="cellule" style="height:30px; border-bottom: 1px dotted #9DACB6"><input type="submit" value="<?php echo trad('Enregistrer'); ?>" /></div>
			</li>

			</form>
			<?php } ?>
			 </ul>
       <div class="bloc_fleche" style="cursor:pointer" onclick="$('#pliantsfichier').hide();"><img src="gfx/fleche_accordeon_img_up.gif" /></div>
</div>
</div> <!-- fin bloc-photos colonne de droite -->
   <?php } ?>
</div>
<?php require_once("pied.php"); ?>
</div>
</div>

</body>
</html>